<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>预约管理
            <small>检查项管理</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>预约管理</el-breadcrumb-item>
            <el-breadcrumb-item>检查项管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="项目编码/项目名称" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>
                <el-button type="primary" class="butT"><a href="http://localhost:83/member/download.do">下载为excel</a></el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="fileNumber" label="档案号" align="center"></el-table-column>
                <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                <el-table-column prop="sex" label="性别" align="center"></el-table-column>
                <el-table-column prop="age" label="年龄" align="center"></el-table-column>
                <el-table-column prop="health_manager" label="健康管理师" align="center"></el-table-column>
                <el-table-column prop="phoneNumber" label="手机号号码" align="center"></el-table-column>
                <el-table-column prop="regTime" label="注册时间" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 新增标签弹层 -->
            <div class="add-form">
                <el-dialog title="新增会员" :visible.sync="dialogFormVisible">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                                         label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="档案号" prop="fileNumber">
                                                <el-input v-model="formData.fileNumber"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="身份证" prop="idCard">
                                                <el-input v-model="formData.idCard"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="登录密码" prop="password">
                                                <el-input v-model="formData.password"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="手机号" prop="phoneNumber">
                                                <el-input v-model="formData.phoneNumber"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="姓名" prop="name">
                                                <el-input v-model="formData.name"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="性别" prop="sex">
                                                <el-select v-model="formData.sex">
                                                    <el-option label="男" value="男"></el-option>
                                                    <el-option label="女" value="女"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="民族" prop="nation">
                                                <el-input v-model="formData.nation"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="年龄" prop="age">
                                                <el-input v-model="formData.age"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="出生日期" prop="birthday">
                                                <el-date-picker type="date" placeholder="选择日期" v-model="formData.birthday"  value-format="yyyy-MM-dd"  style="width: 100%;"></el-date-picker>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="邮箱" prop="email">
                                                <el-input v-model="formData.email"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="婚姻状态" prop="marital_status">
                                                <el-input v-model="formData.marital_status"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="职业" prop="profession">
                                                <el-input v-model="formData.profession"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="文化程度" prop="culture">
                                                <el-input v-model="formData.culture"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="籍贯" prop="native_place">
                                                <el-input v-model="formData.native_place"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="健康管理师" prop="health_manager">
                                                <el-select style="width:77%" v-model="formData.health_manager" placeholder="请选择">
                                                    <el-option
                                                            v-for="item in options"
                                                            :key="item.id"
                                                            :value="item.username"
                                                            :label="item.username">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="档案状态" prop="file_status">
                                                <el-select v-model="formData.file_status">
                                                    <el-option label="启用" value="启用"></el-option>
                                                    <el-option label="禁用" value="禁用"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="备注">
                                                <el-input v-model="formData.remark" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="动态信息" name="second">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="身高">
                                                <el-input v-model="formData.stature"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="体重">
                                                <el-input v-model="formData.weight"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="舒张压">
                                                <el-input v-model="formData.diastolic_blood_pressure"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="收缩压">
                                                <el-input v-model="formData.systolic_pressure"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="呼吸">
                                                <el-input v-model="formData.respiratory_frequency"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="体温">
                                                <el-input v-model="formData.animal_heat"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="腰围">
                                                <el-input v-model="formData.waistline"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="臀围">
                                                <el-input v-model="formData.hipline"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="BMI">
                                                <el-input v-model="formData.BMI"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="血氧饱和度">
                                                <el-input v-model="formData.oxyhemoglobin_saturation"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="病史" name="medical_history">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="既往史">
                                                <el-input v-model="formData.previous_history"
                                                          type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="家族史">
                                                <el-input v-model="formData.family_history" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="过敏史">
                                                <el-input v-model="formData.allergic_history"
                                                          type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="病史">
                                                <el-input v-model="formData.medical_history" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="慢性病">
                                                <el-input v-model="formData.chronic_disease" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>

                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                        <el-button type="primary" @click="handleAdd()">确定</el-button>
                    </div>
                </el-dialog>
            </div>

            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="编辑会员" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                                         label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="档案号" prop="fileNumber">
                                                <el-input v-model="formData.fileNumber"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="身份证" prop="idCard">
                                                <el-input v-model="formData.idCard"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="登录密码" prop="password">
                                                <el-input v-model="formData.password"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="手机号" prop="phoneNumber">
                                                <el-input v-model="formData.phoneNumber"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="姓名" prop="name">
                                                <el-input v-model="formData.name"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="性别" prop="sex">
                                                <el-select v-model="formData.sex">
                                                    <el-option label="男" value="男"></el-option>
                                                    <el-option label="女" value="女"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="民族" prop="nation">
                                                <el-input v-model="formData.nation"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="年龄" prop="age">
                                                <el-input v-model="formData.age"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="出生日期" prop="birthday">
                                                <el-date-picker type="date" placeholder="选择日期" v-model="formData.birthday"  value-format="yyyy-MM-dd"  style="width: 100%;"></el-date-picker>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="邮箱" prop="email">
                                                <el-input v-model="formData.email"/>
                                            </el-form-item>

                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="婚姻状态" prop="marital_status">
                                                <el-input v-model="formData.marital_status"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="职业" prop="profession">
                                                <el-input v-model="formData.profession"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="文化程度" prop="culture">
                                                <el-input v-model="formData.culture"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="籍贯" prop="native_place">
                                                <el-input v-model="formData.native_place"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="健康管理师" prop="health_manager">
                                                <el-select style="width:77%" v-model="formData.health_manager" placeholder="请选择">
                                                    <el-option
                                                            v-for="item in options"
                                                            :key="item.id"
                                                            :value="item.username"
                                                            :label="item.username">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="档案状态" prop="file_status">
                                                <el-select v-model="formData.file_status">
                                                    <el-option label="启用" value="启用"></el-option>
                                                    <el-option label="禁用" value="禁用"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="备注">
                                                <el-input v-model="formData.remark" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="动态信息" name="second">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="身高">
                                                <el-input v-model="formData.stature"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="体重">
                                                <el-input v-model="formData.weight"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="舒张压">
                                                <el-input v-model="formData.diastolic_blood_pressure"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="收缩压">
                                                <el-input v-model="formData.systolic_pressure"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="呼吸">
                                                <el-input v-model="formData.respiratory_frequency"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="体温">
                                                <el-input v-model="formData.animal_heat"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="腰围">
                                                <el-input v-model="formData.waistline"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="臀围">
                                                <el-input v-model="formData.hipline"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="BMI">
                                                <el-input v-model="formData.BMI"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="血氧饱和度">
                                                <el-input v-model="formData.oxyhemoglobin_saturation"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="病史" name="medical_history">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="既往史">
                                                <el-input v-model="formData.previous_history"
                                                          type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="家族史">
                                                <el-input v-model="formData.family_history" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="过敏史">
                                                <el-input v-model="formData.allergic_history"
                                                          type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="病史">
                                                <el-input v-model="formData.medical_history" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="慢性病">
                                                <el-input v-model="formData.chronic_disease" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                        <el-button type="primary" @click="handleEdit()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data: {
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null,//查询条件
                options:[],
                value:'',
            },
            dataList: [],//列表数据
            formData: {},//表单数据
            tableData:[],//新增和编辑表单中对应的检查项列表数据
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit:false,//控制编辑窗口显示/隐藏
            rules: {//校验规则
                fileNumber: [{required: true, message: '档案号为必填项', trigger: 'blur'}],
                name: [{required: true, message: '姓名为必填项', trigger: 'blur'}],
                password: [{required: true, message: '登录密码为必填项', trigger: 'blur'}],
                sex: [{required: true, message: '性别为必选项', trigger: 'blur'}],
                birthday: [{required: true, message: '出生年月为必填项', trigger: 'blur'}],
                health_manager: [{required: true, message: '健康管理员为必选项', trigger: 'blur'}],
                idCard: [{required: true, message: '身份证为必填项', trigger: 'blur'}],
                phoneNumber: [{required: true, message: '手机号为必填项', trigger: 'blur'}],
                marital_status: [{required: true, message: '婚姻状态为必填项', trigger: 'blur'}],
                file_status: [{required: true, message: '档案状态为必选项', trigger: 'blur'}],
                email: [{required: true, message: '邮箱状态为必选项', trigger: 'blur'}],
                age: [{required: true, message: '年龄为必选项', trigger: 'blur'}],
            }
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
            this.getAddress();
        },
        methods: {
            download(){
              axios.post("/member/download.do").then(res =>{
                    window.location.href="../../template/ordersetting_template.xlsx"
              } )
            },


            //编辑
            handleEdit() {

                axios.post("/member/edit.do", this.formData).then((resp) => {
                    //验证修改是否成功
                    if (resp.data.flag) {
                        //成功后，修改层进行隐藏
                        this.dialogFormVisible4Edit = false;
                    }
                }).finally(() => {
                    //最终执行分页方法
                    this.findPage();
                })

            },
            //添加
            handleAdd() {

                //调用验证方法,检查必填项
                this.$refs['dataAddForm'].validate((validate) => {//400 bad request
                    //如果必填项已填则返回true 否则返回false
                    if (validate) {
                        //发送post请求，携带javaBean，进行后台添加操作
                        //var _this = this;

                        console.log(this.formData);
                        axios.post("/member/add.do", this.formData).then((resp) => {
                            this.resetForm();
                            this.dialogFormVisible = false;
                        })


                    } else {

                    }
                })
            },


            //分页查询
            findPage() {
                //定义对象，对其属性赋初始值
                var param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString
                };
                //发送请求，进行分页查寻
                axios.post("/member/findByPage.do", param).then((resp) => {
                    this.pagination.total = resp.data.total;
                    this.dataList = resp.data.rows;

                })
            },
            // 重置表单
            resetForm() {
                this.formData={};
                this.findPage();
            },
            // 弹出添加窗口
            handleCreate() {
                this.resetForm();
                this.dialogFormVisible = true;
            },
            // 弹出编辑窗口
            handleUpdate(row) {
                this.resetForm();
                this.dialogFormVisible4Edit = true;
                axios.get("/member/findById.do?id=" + row.id).then(resp => {
                    //数据回显
                    this.formData = resp.data;
                })
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            // 删除
            handleDelete(row) {
                //alert(row.id);
                this.$confirm("你确定要删除当前数据吗？","提示",{//确认框
                    type:'warning'
                }).then(()=>{
                    //用户点击确定按钮，发送ajax请求，将检查项ID提交到Controller进行处理
                    axios.get("/member/delete.do?id=" + row.id).then((res) => {
                        if(res.data.flag){
                            //执行成功
                            //弹出成功提示信息
                            this.$message({
                                type:'success',
                                message:res.data.message
                            });
                            //重新进行分页查询
                            this.findPage();
                        }else{
                            //执行失败
                            this.$message.error(res.data.message);
                        }
                    });
                }).catch(()=>{
                    this.$message({
                        type:'info',
                        message:'操作已取消'
                    });
                });
            },

            getAddress(){
                axios.post("/member/getAddress.do").then(res =>{
                    this.options=res.data;
                })
            }
        }
    })
</script>
</html>